#include <bits/stdc++.h>
using namespace std;
string tmp, s;
int MODE = 1;  // 1 按强评排序，2 按强单排序，3 按普评排序
struct Node {
  string name;
  int score;
  bool operator<(const Node &o) const {
    return score == o.score ? name > o.name : score > o.score;
  }
};
int num(char x, int y) {
  int ret = x - '0';
  for (int i = 1; i < y; i++) ret *= 10;
  return ret;
}
set<Node> S;
int main() {
  while (getline(cin, s)) {
    Node x;
    x.name = s;
    int i = 0;
    for (; i < s.size(); i++)
      if (s[i] == '@') break;
    for (int k = 1; k <= MODE; k++) {
      for (; i < s.size(); i++)
        if (s[i] == '|') break;
      i++;
    }
    if (s[i + 1] == ' ')
      x.score = num(s[i + 2], 4) + num(s[i + 3], 3) + num(s[i + 4], 2) +
                num(s[i + 5], 1);
    else
      x.score = num(s[i + 1], 4) + num(s[i + 2], 3) + num(s[i + 3], 2) +
                num(s[i + 4], 1);
    S.insert(x);
  }
  for (auto x : S) cout << x.name << endl;
}